<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录 workerman.net 官网</title>
    <link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/app/admin/admin/css/pages/login.css" />
</head>
<body style="background: #fff !important;">
<form class="layui-form" style="margin-top:36px !important;">
    <div class="layui-form-item pear-border" style="background:#ebf2f8;border:1px solid #ccddf6;padding:10px;border-radius: 4px;">
        <div class="pear-text">注意此处登录 <a class="pear-text" href="https://www.workerman.net" target="_blank"><b>workerman.net</b></a> 官网账号</div>
    </div>
    <div class="layui-form-item">
        <input lay-verify="required" hover class="layui-input" type="text" name="username" value="" />
    </div>
    <div class="layui-form-item">
        <input lay-verify="required" hover class="layui-input" type="password" name="password" value="" />
    </div>
    <div class="layui-form-item">
        <input hover  lay-verify="required" class="code layui-input layui-input-inline" name="captcha" />
        <img class="codeImage" width="120px"/>
    </div>
    <div class="layui-form-item">
        <button type="submit" class="pear-btn pear-btn-primary login" lay-submit lay-filter="login">
            登录
        </button>
    </div>
</form>

<script src="/app/admin/component/layui/layui.js"></script>
<script src="/app/admin/component/pear/pear.js"></script>
<script>
  layui.use(["form", "button", "popup", "layer"], function() {
    var $ = layui.$, layer = layui.layer, form = layui.form;
    function switchCaptcha() {
      $(".codeImage").attr("src", "/app/admin/plugin/captcha?v=" + new Date().getTime());
    }
    switchCaptcha();
    form.on("submit(login)", function (data) {
      layer.load();
      $.ajax({
        url: "/app/admin/plugin/login",
        type: "POST",
        data: data.field,
        success: function (res) {
          layer.closeAll("loading");
          if (!res.code) {
            layui.popup.success("登录成功", function () {
              parent.layer.close(parent.layer.getFrameIndex(window.name));
            })
          } else {
            layui.popup.failure(res.msg, function () {
              switchCaptcha();
            })
          }
        }
      });
      return false;
    });
    $(".codeImage").on("click", function () {
      switchCaptcha();
    });
  })
</script>
</body>
</html>
